local skel = fk.CreateSkill {
  name = "emo__youtian",
}

Fk:loadTranslationTable{
  ["emo__youtian"] = "游畋",
  [":emo__youtian"] = "当装备牌进入你装备区后，若未替换装备牌，你摸一张牌。若你装备武器/坐骑牌，你使用的【杀】可改为冰/刺【杀】。",

  ["#emo__youtian-choice"] = "游畋：你可以改变使用的【杀】的属性",
}

skel:addEffect(fk.AfterCardsMove, {
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(skel.name) then return false end
    local draw = false
    for _, move in ipairs(data) do
      if move.to == player and move.toArea == Card.PlayerEquip then draw = true end
      if move.from == player then
        for _, info in ipairs(move.moveInfo) do
          if info.fromArea == Card.PlayerEquip then
            return false
          end
        end
      end
    end
    return draw
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    player:drawCards(1, skel.name)
  end,
})

skel:addEffect(fk.AfterCardUseDeclared, {
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(skel.name) and data.card.trueName == "slash"
    and (((player:getEquipment(Card.SubtypeOffensiveRide) ~= nil or player:getEquipment(Card.SubtypeDefensiveRide) ~= nil)
    and data.card.name ~= "stab__slash")
    or (player:getEquipment(Card.SubtypeWeapon) ~= nil and data.card.name ~= "ice__slash"))
  end,
  on_cost = function (self, event, target, player, data)
    local choices = {}
    if player:getEquipment(Card.SubtypeWeapon) ~= nil then
      table.insert(choices, "ice__slash")
    end
    if player:getEquipment(Card.SubtypeOffensiveRide) ~= nil or player:getEquipment(Card.SubtypeDefensiveRide) ~= nil then
      table.insert(choices, "stab__slash")
    end
    table.removeOne(choices, data.card.name)
    if #choices > 0 then
      table.insert(choices, "Cancel")
      local choice = player.room:askToChoice(player, {choices = choices, skill_name = skel.name, prompt = "#emo__youtian-choice"})
      if choice == "Cancel" then return end
      event:setCostData(self, choice)
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    data:changeCard(event:getCostData(self), data.card.suit, data.card.number, skel.name)
  end,
})

return skel
